<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui">

    <h:form id="PacchettoListForm">

        <p:panel header="#{myBundle.ListPacchettoTitle}">

            <p:dataTable id="datalist" value="#{pacchettoController.items}" var="item"
                         selectionMode="single" selection="#{pacchettoController.selected}"
                         rowKey="#{item.idPACCHETTO}"
                         paginator="true"
                         rows="10"
                         rowsPerPageTemplate="10,20,30"
                         >

                <p:ajax event="rowSelect"   update="viewButton addButton"/>
                <p:ajax event="rowUnselect" update="viewButton addButton"/>

                <p:column sortBy="#{item.idPACCHETTO}" filterBy="#{item.idPACCHETTO}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListPacchettoTitle_idPACCHETTO}"/>
                    </f:facet>
                    <h:outputText value="#{item.idPACCHETTO}"/>
                </p:column>
                <p:column sortBy="#{item.titolo}" filterBy="#{item.titolo}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListPacchettoTitle_titolo}"/>
                    </f:facet>
                    <h:outputText value="#{item.titolo}"/>
                </p:column>
                <p:column sortBy="#{item.sconto}" filterBy="#{item.sconto}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListPacchettoTitle_sconto}"/>
                    </f:facet>
                    <h:outputText value="#{item.sconto}"/>
                </p:column>
                <p:column sortBy="#{item.disponibilita}" filterBy="#{item.disponibilita}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListPacchettoTitle_disponibilita}"/>
                    </f:facet>
                    <h:outputText value="#{item.disponibilita}"/>
                </p:column>
                <p:column sortBy="#{item.dataCreazione}" filterBy="#{item.dataCreazione}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListPacchettoTitle_dataCreazione}"/>
                    </f:facet>
                    <h:outputText value="#{item.dataCreazione}">
                        <f:convertDateTime pattern="MM/dd/yyyy" />
                    </h:outputText>
                </p:column>
                <f:facet name="footer">
                    <div class="footer-section">
                       <p:commandButton id="viewButton"  actionListener="#{travelId.update}" icon="ui-icon-search" value="View elements" action="/user/viewPackage" disabled="#{empty pacchettoController.selected}">
                           <f:param name="idViaggio" value="#{pacchettoController.selected.idPACCHETTO}" />
                       </p:commandButton>

                       <p:commandButton id="addButton"   icon="ui-icon-add" value="Add package to travels" actionListener="#{pacchettoviaggioController.prepareCreate}" update=":PacchettoviaggioCreateForm" oncomplete="PacchettoviaggioCreateDialog.show()"/>
                    </div>
                </f:facet>

            </p:dataTable>

        </p:panel>

    </h:form>

</ui:composition>